home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ADA Programming Guide
/
ADA Programming Guide.iso
/
ada_a9x
/
fat.ada
< prev
next >
Wrap
Text File
|
1996-01-30
|
437b
|
24 lines
PRAGMA LIST(On);
WITH Ada.Text_IO; USE Ada.Text_IO;
PROCEDURE Factorial IS
FUNCTION Fat(N : Integer) RETURN Integer IS
BEGIN
IF N <= 1 THEN
RETURN 1;
ELSE
RETURN N * Fat(N - 1);
END IF;
EXCEPTION
WHEN Numeric_Error =>
return -1;
END Fat;
BEGIN
FOR I IN 2 .. 8 LOOP
Put("O Fatorial de ");
Put(Integer'IMAGE(I));
Put(" e' ");
Put_Line(Integer'IMAGE(Fat(I)));
END LOOP;
END Factorial;